<div class="catListings">
	<h3 class="sideTitle">Categories</h3>
	<?php
	$level = 0;
	echo '<ul id="menu" class="level1">';
	if ($categories->num_rows() > 0)
	{
		foreach ($categories->result() as $row)
		{
			if($row->parent_category_id == 0)
			{
				$tree_start = $row->tree_start;
				$tree_end = $row->tree_end;
				echo '<li><a rel="noindex,follow" href="',get_category_url($row, 1),'">', $row->category_name, ( $tree_start != $tree_end  ?  '<span></span>' : ''),'</a></li>';
				
			}
			else 
			{	
				if($row->tree_order == $tree_start + 1) 
					echo '<ul class="level2">';					
				
				echo '<li><a rel="noindex,follow" href="',get_category_url($row, 1),'">', $row->category_name, '</a></li>';
				
				if($row->tree_order == $tree_end) 
					echo '</ul></li>';

			}
		
		}

	}
	echo '</ul>';
	?>
</div>